package com.lingchou.cloud.process.client.util;


import com.lc.common.exception.HandlerException;
import com.lingchou.cloud.process.api.enums.CommentTypeEnum;

/**
 * 用于存储流程状态对象。
 */
public class ThreadLocalUtil {
    private static final ThreadLocal<CommentTypeEnum> THREAD_LOCAL_STATUS = new ThreadLocal<>();

    public static void putStatus(CommentTypeEnum commentTypeEnum){
        if(commentTypeEnum == null){
            throw new HandlerException("状态为空");
        }
        THREAD_LOCAL_STATUS.set(commentTypeEnum);
    }

    public static CommentTypeEnum popStatus(){
        return THREAD_LOCAL_STATUS.get();
    }

    public static void remove(){
        THREAD_LOCAL_STATUS.remove();
    }
}
